package bin_tree;

import java.util.Scanner;

/**
 * @author shkstart
 * @create 2022-11-05-10:47
 */
class NUM360Test {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        NUM360Test num360Test= new NUM360Test();
        int n = scanner.nextInt();
        int m = scanner.nextInt();
        int []nums = new int[n];
        for (int i = 0; i < n; i++) {
            nums[i] = scanner.nextInt();
        }

        for (int i = 0; i < m; i++) {
            int t= scanner.nextInt();
            int x= scanner.nextInt();
            if(0==t){
                num360Test.swapMax(nums,x);
            }else{
                num360Test.swapMin(nums,x);
            }
        }

        for (int arr:nums) {
            System.out.print(arr+" ");
        }





    }
    public void swapMax(int[]nums,int x ){
        for (int j = 0; j < x-1; j++) {
            for (int k = 0; k <x-j-1 ; k++) {
                if(nums[k]>nums[k+1]){
                    int temp  =nums[k];
                    nums[k]=nums[k+1];
                    nums[k+1]= temp;
                }
            }
        }
    }
    public void swapMin(int[]nums,int x ){
        for (int j = 0; j < x-1; j++) {
            for (int k = 0; k <x-j-1 ; k++) {
                if(nums[k]<nums[k+1]){
                    int temp  =nums[k];
                    nums[k]=nums[k+1];
                    nums[k+1]= temp;
                }
            }
        }
    }

}
